// Readonly field
class Greeter {
    constructor(readonly message: string) {
    }
    greet() {
        return "Hello, " + this.message;
    }
}
let greeter = new Greeter("world");
console.log(greeter.greet())


// Readonly cannot be modified
class Octopus {
    readonly name: string;
    readonly numberOfLegs: number = 8;
    constructor(theName: string) {
        this.name = theName;
    }
}
let dad = new Octopus("Man with the 8 strong legs");
// dad.name = "Man with the 3-piece suit"; // error! name is readonly.

// Class as interface
class Point {
    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }
    x: number;
    y: number;
}
interface Point3d extends Point {
    z: number;
}
let point3d: Point3d = { x: 1, y: 2, z: 3 };

// Interface as structure defination
interface Point {
    x: number; y: number;
}
class MyPoint implements Point {
    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }
    x: number; y: number; // Same as Point
}
var foo: Point = new MyPoint(3, 4);

// Interface as function defination (function is a component of structure)
interface Shooter {
    name: string;
    shoot(): void;
}
class PoliceMan implements Shooter {
    name: string;
    shoot(): void {
        console.log("Stop! You're under arrest!")
    }
}
const black: PoliceMan = new PoliceMan();
black.shoot()